/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aiaudio.processing.split;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.WritableComparable;

/**
 *
 * @author nastya
 */
public class UserValueKey implements WritableComparable<UserValueKey> {
    private String user;
    private String key;
    private int value;

    public UserValueKey(String user, String key, int value) {
        this.user = user;
        this.key = key;
        this.value = value;
    }

    public UserValueKey() {
    }

    public byte[] getKeyAsBytes() {
        return Bytes.toBytes(key);
    }

    public byte[] getUserAsBytes() {
        return Bytes.toBytes(user);
    }

    public byte[] getValueAsBytes() {
        return Bytes.toBytes(value);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        user = in.readUTF();
        key = in.readUTF();
        value = in.readInt();
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeUTF(user);
        out.writeUTF(key);
        out.writeInt(value);
    }

    @Override
    public int compareTo(UserValueKey t) {
        if(t == null){
            return 1;
        }
        
        return user.compareTo(t.user);
    }
    
    
    
    
}
